'''
弹出框：
    1）警告框  提示信息+确认按钮
    2）确认框   提示信息+确认+取消  是否删除
    3）提示框  输入 确认  取消
切换到弹出框
switch_to.alter
获取弹出框的信息 text
确认 accpet
取消 dismiss
输入信息：send_keys()
'''
import time


from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

driver = webdriver.Edge()
driver.get("http://127.0.0.1/ranzhi/www/")
time.sleep(1)

# 用户名密码
driver.find_element("xpath",'//*[@id="account"]').send_keys("admin")
driver.find_element("xpath",'//*[@id="password"]').send_keys("123456")
# 点击登录
driver.find_element("xpath",'//*[@id="submit"]').click()
time.sleep(1)

# 点击文档
driver.find_element("id","s-menu-4").click()

# 切换到iframe
driver.switch_to.frame(driver.find_element("id","iframe-4"))

# 点击其中一个文档库
driver.find_element("class name","libs-group-heading.libs-custom-heading").click()

# 点击创建文档
driver.find_element("class name","btn.btn-primary").click()

# 选择文件 大文件
a = driver.find_element("name","files[]")
# a.send_keys("d:\\cat.jpeg")
a.send_keys("e:\\spring-tool-suite-3.9.0.RELEASE-e4.7.0-win32-x86_64 (1).zip")
# 切换到提示框
alter1 = driver.switch_to.alert
# 获取提示框的文本信息
print(alter1.text)

# 提示框的确认
alter1.accept()

time.sleep(20)

# 切换到上一层
driver.switch_to.default_content()
# driver.switch_to.parent_frame()

# 点击签退
driver.find_element("class name","sign.signout").click()

time.sleep(20)